package com.baizhi.controller;

import com.baizhi.entrty.Album;
import com.baizhi.entrty.Audio;
import com.baizhi.service.AlbumService;
import com.baizhi.service.AudioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class AudioController {
    @Autowired
    private AudioService as;
    @Autowired
    private AlbumService ass;

    @RequestMapping("tree")
    @ResponseBody
    public List<Album> getTree(){

        return ass.getTree();
    }

    @RequestMapping("insertAudio")
    @ResponseBody
    public Map insert(Audio audio){
        Map map = new HashMap();
        try {
            System.out.println(audio+"----------audio");
            System.out.println(audio+"----------audio");
            System.out.println(audio+"----------audio");
            System.out.println(audio+"----------audio");
            as.insert(audio);
            map.put("myinsertAudio",true);
        } catch (Exception e) {
            map.put("myinsertAudio",false);
            e.printStackTrace();
        }
        return map;
    }
}
